package com.liang.consumer;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.impl.AMQImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.UnsupportedEncodingException;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: XIAOLIANG
 * Date: 2021/6/19
 * Time: 0:12
 * Description: 队列TTl 的消费者
 */

@Slf4j
@Component
public class DeadLetterQueueConsumer {


    //接受消息
    @RabbitListener(queues = "QD")
    public void receiveD(Message message, Channel channel) throws UnsupportedEncodingException {

        String msg = new String(message.getBody(),"UTF-8");

        log.info("当前时间:{},收到死信队列的消息:{}",new Date().toString(),new String(message.getBody()));


    }

}